package com.wolf.etl.vo;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by tommy's father on 2017/8/20.
 */
//数据库-表格
public class Table {
    //表名
    private String name;
    //类别名
    private String catalog;
    //模式名
    private String schema;
    //列的集合
    private final Map<String, Column> columns = new HashMap<String, Column>();
    //主键列
    private Column primaryKey;

    //构造方法
    public Table(String name) {
        this.name = name;
    }

    public void addColumn(Column column) {
        this.columns.put(column.getName(), column);
    }

    public Column getColumn(String name) {
        for (Column column : columns.values()) {
            if (column.getName().equalsIgnoreCase(name)) {
                return column;
            }
        }
        return null;
    }

    //getter/setter方法
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getCatalog() {
        return catalog;
    }

    public void setCatalog(String catalog) {
        this.catalog = catalog;
    }

    public String getSchema() {
        return schema;
    }

    public void setSchema(String schema) {
        this.schema = schema;
    }

    public Map<String, Column> getColumns() {
        return columns;
    }

    public Column getPrimaryKey() {
        return primaryKey;
    }

    public void setPrimaryKey(Column primaryKey) {
        this.primaryKey = primaryKey;
    }
}
